In the time of Ramayana, by the performance of penance, one could achieve his inherent desires in the real life, and such wishes valued very high in the world.
Mayasura was an able architect. So he prayed God Shiva to bless him with a beautiful lady as his wife in order to keep his family status high before the angels of heaven, with Indra or before the Asuras. God Shiva agreed to his prayer, being his first request, and created an Apsara with name Hema and gave to him as his wife. He also warned him he would not grant him anything so easily if he turns towards God Shiva again with another request.
