Besides the one-time fee of purchasing Minecraft, users also have to pay a subscription in order to play online on the official servers. However, you can follow this article to see how you can create servers for you and your friends for free.