He has waited a thousand years trapped inside this bottle, buried underneath the sand. The last person to set him free was a child who used her wishes for a billion grapes, never sleeping again, and kittens.
Those were a fun few days, but then back into the bottle he was forced to go. Stolen, taken half away around the world then lost, waiting an hour after hour for the next person to come along.
His selfishness is why he became this cursed creature. If he had shared his bread with that hungry widow and children, helping them instead of making them watch eat every morsel; the widow wouldn't have cursed him.