Hi Noé, and any other newcomer to phylogeneticsm
Alexi answered the basic question, which was double posted, here's the cross-link:
But I like to take the opportunity to remind once more (the question pops up regularly on the RAxML forum) that we do not infer rooted trees with most tree inference implementations (knowing that many lectures still get this wrong). Irrespective of whether we use or not the --outgroup option, we (typically) optimise unrooted trees, build up by a sequence of compatible taxon (tip) bipartitions such as A + B | C + D + E and A + B + C | D + E.
Unfortunately, the NEWICK format we use to encode an inferred tree doesn't do unrooted trees, it's not internode-(branch) but node-based, hence, any NEWICK tree is intrinsically rooted (by default in RAxML using the top-level trifurcation, or the pre-defined outgroup-ingroup internode when using the --outgroup option).
For the above case, we can define the same tree with different NEWICK codes ((A,B),(C(D,E)), placing the tree's root between AB and CDE or
(((A,B),C)(D,E)) placing the root between ABC and DE, or (A(B(C(D,E)))) designating A as the outgroup. These are different rooted versions of the same inferred (unrooted), optimised tree.
Outgroup rooting (as invoked with the --outgroup option) is hence merely a post-inference graphical modification, a graphical interpretation of the tree under the assumption that our outgroup is not part of the ingroup. So, indeed, if we reroot a tree (really: the classic paper in Alexi's answer is a must-read!), it's just a reassignment, it doesn't change the tree.
There are some explicitly rooted inferred trees such as when we use asymmetrical (direct) substitution models, e.g., simplest case, a model than only allows Dollo mutations from 0 to 1 for a binary data set. Such a tree will assume the root is an all-zero ancestor from which all tips evolved by changing 0s to 1s.
Also chronograms are intrisically rooted being ultrametrised: the optimised clock model implicitly roots the inferred tree even in the absence of an outgroup. Clock-rooting is a valid, although much underused, alternative to outgroup-rooting and can be especially an option for population-level data or any data set with an ingroup that lacks a meaningfully close outgroup, i.e. where any sampled outgroup taxon is sequentially very different from all ingroup tips and may be prone to ingroup-outgroup long-branch attraction (note that ML only escapes LBA in 50% of the cases in the Felsenstein Zone, MP and distance-based approaches will always be wrong).
A not much used but very quick&handy test of outgroup-triggered roots is to use the outgroup sample as queries and optimise their position on an ingroup-only tree using RAxML's evolutionary placement algorithm (example below, test of a genus root, from
Liede-Schumann et al. 2020, open access): if they do not map on the same internode, outgroup rooting is problematic or the outgroup sample includes better-suited outgroups and outgroups that may trigger ingroup-outgroup branching artefacts.