Spring is a simpler alternative to JavaEE and evolves much quicker than the JavaEE specification, often times innovating where JavaEE would then follow and implement specifications only after Spring implemented it. Spring for example had @Autowired for ages, only in JavaEE6 did JavaEE get an equivalent @Inject. Some people prefer the slow-pace of JavaEE over Spring's more rapidly evolving specifications.
When the only options were JavaEE or Spring, your options were
1: go with JavaEE and get stuck in a JavaEE container (like JBoss); new functionality only became available every 5-or-so years and you were limited to the versions of JARs that your container offered you. Your deployable WARs were very small though since half the JARs were already embedded into the container.
2: go with Spring, don't have access to the majority of the JavaEE specifications (like JMS), build fully self-contained WAR files that were often 20MB+ in size, but you could easily move around between containers that were more lightweight (like Tomcat and Jetty)
AspectJ which Spring makes heavily use of for its annotations as well as weaving in things that would be hard to do with pure Java, made Spring nice to have in a project as it reduced a lot of boilerplate. Some people joke that Spring is considered Annotation Orientated Programming. After switching to Kotlin, AspectJ actually gets in my way and I no longer reap any benefits from it.
With modern frameworks / libraries and the appearance of microservice-frameworks like VertX, Ratpack, Dropwizard, etc, I've abandoned Spring completely since I no longer see any benefit in having a framework wrap every library I want to use with Spring boilerplate.
The above is completely my opinion and not intended to start a JavaEE VS Spring flamewar.