Playing from memory is a very useful skill. The more that you can place in your memory, the better off you will be. This is true for everything, but I believe that it is also true for music. In fact I believe that music is often used to teach other subjects. For example, the alphabet is taught as a song. So memorizing songs are an easy way to learn things in general.
Similarly, I believe that learning to play by ear is encouraged by memorizing songs. The reason is that the more songs you learn, the more patterns you recognize. Why is this important? Songs are made up of things called Progressions. A progression is a collection of chords that make up any particular song. Each series of chords or progression, form the song when placed together.
The more times you play a song, it engraves itself in your mind and you are able to retain it much better. So I encourage you to learn as many songs as you can from memory, and you will find yourself playing by ear.