In fact there are three soliloquies before 'To be or not to be.' All are concerned with performing the deed of revenge; absolute determination. In Act 1 scene ii a depressed Hamlet is coping with grief. 'Break my heart for I must hold my tongue.' In Act 1 scene V Hamlet says of his father 'and thy commandment all alone shall live ...' He's ridding himself of external distractions to focus on revenge alone. 'I'll wipe away all trivial fond records'. In Act 2 scene 2 there's the speech: 'What's Hecuba to him or he to Hecuba ...' Hamlet is berating himself for delaying, is still determined.
The 'to be or not to be' soliloquy is different. He talks about things that trouble him - a longing to die, a longing to sleep (but the danger that he will dream), the fear of the unknown i.e. what exists after death. 'Thus conscience doth make cowards of us all' is often misinterpreted; 'conscience' here refers to consciousness, or the state of contemplation and thought and worry. So, 'the native hue of resolution is sicklied o'er with the pale cast of thought.' That is, he is becoming locked into debates with himself, excuses and inaction.
This is a bland explanation of some tremendous speeches. Hamlet's grief and intellect scream out. They are wonderful emotional outpourings.