Monolithic architecture is a traditional approach to software development in which the entire system is packaged and deployed as a single unit. In this architecture, all the functionalities of a project exist in a single codebase.
Monolithic architecture is simple to develop and test. They are easy to scale and deploy. However, they suffer from tight coupling, low flexibility, and size limitation issues which can slow down the start-up time and makes the whole system very complex to maintain.
In a microservice architecture, business logic is broken down into lightweight, single-purpose self-sufficient services. These services interact by means of API. Microservice architecture tackles the problem of complexity and enables each service to be developed independently. It reduces the barrier of adopting new technologies, enables each microservice to be deployed independently, and allows each service to be scaled independently.
Monolithic architecture is preferred when you're planning a small application or working in a small team or when you're building an MVP, and you're at an ideation stage.
Similarly, microservice architecture is preferred when you're building a large-scale application, and you need independent components for different services. It is preferred when you have a lot of time and plan to grow your team.