There are many ways to improve your science rate - either switch off research and trade for techs with the cash you save, or go to war frequently and extort techs from your neighbours for peace, or you may even decide to develop libraries and universities as much as possible and research yourself. These options may all be used at different times during a single game.
Republic and Democracy are not mandatory. During recent games I only revolted to monarchy, as I knew I wanted to win by military means and monarchy pays for a big army and eliminates war weariness.
Your early development phase to around 1000 BC is usually crucial as that determines the size of your economy and hence your trading and research capabilities, the strength of your army, and your number of cities. The last two factors determine whether the AI will attack you.
Read the timelines in the Succession Games forum and the Spoilers in the Game of the Month forum to see how the experts do it. If you wish, upload an example .SAV file of one of your recent games where the AI has decided to attack. We may be able to identify specific things you can do to improve your results.