Technically speaking, you are allowed to write about whatever you want. There are numerous factors that play into ranking well on search engine results pages like on-page SEO, domain authority/page authority, a secure and accessible website, technical SEO and mobile friendliness. Your chances of ranking well are increased when these factors are in great shape.
When focusing on optimizing your web content (on-page SEO), I prefer to start with keyword research and then form the content around what the main topic is going to be along with the support topics that help drive relevant search queries. Looking at your competitors keywords in your designated space is a great way to form your keyword research list as you mentioned!
MOZ has a great keyword research tool called "keyword explorer" where you can type in the topic you're going after and it will supply a list of keywords in this space. You usually want to go after keywords with a higher search volume (preferably with a lower competition score as well).
Once you completed your keyword research, the next step is to select 1-2 focus keywords to use as your H1 header tags and then select support keywords (5-7 roughly) to use in your H2/H3 title tags and copy. DO NOT keyword stuff. As long as you flow in the keywords naturally and have a fair ratio per the amount of copy on the page, you should be okay.
Best of luck!