I'm writing a discord bot for educational purposes and out of boredom. In many tutorials command functionality is realized through on_message() but I found some that use @bot.command too. I don't have enough experience to tell which will be better in the long run and I didn't find any such information in discord.py docs. Which one should I use and why?
Which one should I use and why?

I would depend what you want to do specifically. on_message is completely open-ended, so if you need to process arbitrary messages and have your bot react then that's the one to use e.g. maybe you want to reply to people using words of more than 4 syllables and tell them their long words hurt or something.
Commands are much more structured and used for explicitly interacting with bots.
So by default you'd use commands, and if your use case doesn't fit commands, then you'd use the more freeform on_message.
Should I use on_message() or @bot.command?